/**
* 版权声明：厦门睿商网络科技有限公司 版权所有 违者必究
* 日    期：2020-02-17
*/
package com.rzico.order.service;

import com.rzico.base.BaseMapper;
import com.rzico.base.impl.BaseServiceImpl;
import com.rzico.order.entity.OrderItem;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.rzico.order.mapper.OrderItemMapper;

import java.math.BigDecimal;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <pre>
 * 订单项业务类
 * </pre>
 *
 * @author Rzico Boot
 * @version 1.0
 */
@Service
public class OrderItemService extends BaseServiceImpl<OrderItem, String> {

    @Autowired
    private OrderItemMapper orderItemMapper;

    @Override
    public BaseMapper<OrderItem, String> getMapper() {
        return orderItemMapper;
    }

    public List<OrderItem> getItemList(Long orderId) {
        Map<String,Object> params = new HashMap<>();
        params.put("orderId",orderId);
        return selectList(params);
    }

    public BigDecimal checkSumProduct(Map<String, Object> params) {
        Map<String,BigDecimal> data = orderItemMapper.checkSumProduct(params);
        if (data !=null && data.containsKey("quantity")) {
            return new BigDecimal(data.get("quantity").toString());
        } else {
            return BigDecimal.ZERO;
        }
    }


}
